﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class ContactPhoneBL
	{

		#region ***** Init Methods ***** 
		ContactPhoneDA objContactPhoneDA;
		public ContactPhoneBL()
		{
			objContactPhoneDA = new ContactPhoneDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get ContactPhone by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>ContactPhone</returns>
        public ContactPhone GetByID(int id, int PersonalProfileID)
		{
            return objContactPhoneDA.GetByID(id, PersonalProfileID);
		}

		/// <summary>
		/// Get all of ContactPhone
		/// </summary>
		/// <returns>List<<ContactPhone>></returns>
		public List<ContactPhone> GetList()
		{
			string cacheName = "lstContactPhone";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objContactPhoneDA.GetList(), "ContactPhone");
			}
			return (List<ContactPhone>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of ContactPhone
		/// </summary>
		/// <returns>DataSet</returns>
        public DataSet GetDataSet(int PersonalProfileID)
		{
			string cacheName = "dsContactPhone";
            ServerCache.Remove("dsContactPhone");
			if( ServerCache.Get(cacheName) == null )
			{
                ServerCache.Insert(cacheName, objContactPhoneDA.GetDataSet(PersonalProfileID), "ContactPhone");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}

        public DataSet GetDataSetOld()
        {
            string cacheName = "dsContactPhone";
            if (ServerCache.Get(cacheName) == null)
            {
                ServerCache.Insert(cacheName, objContactPhoneDA.GetDataSetOld(), "ContactPhone");
            }
            return (DataSet)ServerCache.Get(cacheName);
        }

		/// <summary>
		/// Get all of ContactPhone paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<ContactPhone>></returns>
		public List<ContactPhone> GetListPaged(int recperpage, int pageindex)
		{
			return objContactPhoneDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of ContactPhone paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objContactPhoneDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new ContactPhone within ContactPhone database table
		/// </summary>
		/// <param name="obj_contactphone">ContactPhone</param>
		/// <returns>key of table</returns>
		public int Add(ContactPhone obj_contactphone)
		{
			ServerCache.Remove("ContactPhone", true);
			return objContactPhoneDA.Add(obj_contactphone);
		}

		/// <summary>
		/// updates the specified ContactPhone
		/// </summary>
		/// <param name="obj_contactphone">ContactPhone</param>
		/// <returns></returns>
		public void Update(ContactPhone obj_contactphone)
		{
			ServerCache.Remove("ContactPhone", true);
			objContactPhoneDA.Update(obj_contactphone);
		}

		/// <summary>
		/// Delete the specified ContactPhone
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("ContactPhone", true);
			objContactPhoneDA.Delete(id);
		}
		#endregion
	}
}
